class Solution {
public:
    vector<int> postorderTraversal(TreeNode* root) {
vector<int> m;
stack<TreeNode*> s1;
stack<TreeNode*> s2;
 if(!root) return {};
        s1.push(root);
        while(!s1.empty()) {
            TreeNode* t=s1.top();
            s2.push(t);
            s1.pop();
            if(t->left) s1.push(t->left);
            if(t->right) s1.push(t->right);
        }
        while(!s2.empty()) {
            m.push_back(s2.top()->val);
            s2.pop();
        }
        return m;
    }
};